/**
 * Created by zhaojm on 15/3/29.
 */
game.ExplodeEffect = cc.Class.extend({

    _sprite:null,
    _action : null,
    ctor:function(){

        var winSize = cc.winSize;

        this._sprite = new cc.Sprite(cc.spriteFrameCache.getSpriteFrame('explosion_01.png'));


        var frames = [];
        for(var i = 1; i < 35; i++){
            var idx = '';
            if(i < 10){
                idx = '0' + i;
            }else {
                idx = i + '';
            }
            var frame = cc.spriteFrameCache.getSpriteFrame('explosion_' + idx + '.png');
            frames.push(frame);
        }
        var animation = new cc.Animation(frames, 0.04);

        var removeFunc =  cc.CallFunc.create(this.removeFromLayer);

        this._action = new cc.Sequence(new cc.Animate(animation), removeFunc);

    },

    addToLayer : function(layer, pos){
        layer.addChild(this._sprite);
        this._sprite.setPosition(pos);
        this._sprite.runAction(this._action);
    },

    removeFromLayer : function(pSender){
        pSender.removeFromParent();
    },



});